<?php
$this->beginBlock('toolbar');
$t = $this->toolbar();
echo $t->renderBegin();
echo $t->renderItem($this->link($this->__('system.button.back'), $this->historyUrl('*/*/dms-entity/index')));
echo $t->renderItem($this->link($this->__('system.button.sort'), $this->buildUrl('*/*/*/sort', array('entityid'=>$this->entityId))));
echo $t->renderItem($this->link($this->__('system.button.new'), $this->buildUrl('*/*/*/create', array('entityid'=>$this->entityId))));
echo $t->renderEnd();

$this->nextBlock('grid');
$g = $this->grid('grid', $this->list->toArray());
echo $g->renderBegin();
echo $g->renderHeadBegin();
echo $g->emptyHead()->setStyle('width', 30);
echo $g->htmlHead($this->checkbox()->addClass('row-all-check')->toHtml())->setStyle('width', 30);
echo $g->labelHead($this->__('system.label.name'))->toHtml();
echo $g->labelHead($this->__('system.label.property_type'))->toHtml();
echo $g->labelHead($this->__('system.label.field_type'))->toHtml();
echo $g->labelHead($this->__('system.label.length'))->toHtml();
echo $g->labelHead($this->__('system.label.insertable'))->toHtml();
echo $g->labelHead($this->__('system.label.updateable'))->toHtml();
echo $g->labelHead($this->__('system.label.required'))->toHtml();
echo $g->labelHead($this->__('system.label.increment'))->toHtml();
echo $g->labelHead($this->__('system.label.primary_key'))->toHtml();
echo $g->labelHead($this->__('system.label.versionable'))->toHtml();
echo $g->labelHead($this->__('system.label.default_value'))->toHtml();
echo $g->labelHead($this->__('system.label.input_type'))->toHtml();
echo $g->emptyHead()->setStyle('width', 40);
echo $g->emptyHead()->setStyle('width', 40);
echo $g->renderHeadEnd();
while($g->nextRow()):
	$currentRow = $g->getCurrentRow();
	echo $g->renderRowBegin();
	echo $g->indexCell()->toHtml();
	echo $g->checkboxCell('{id}', 'ids[]')->addClass('row-check')->toHtml();
	echo $g->labelCell('{name}')->toHtml();
    echo $g->labelCell('{property_type}')->toHtml();
    echo $g->labelCell('{field_type}')->toHtml();
    echo $g->labelCell('{length}')->setEmptyText(0)->toHtml();
    echo $g->booleanCell('{insertable}')->toHtml();
    echo $g->booleanCell('{updateable}')->toHtml();
    echo $g->booleanCell('{required}')->toHtml();
    echo $g->booleanCell('{is_increment}')->toHtml();
    echo $g->booleanCell('{is_primary}')->toHtml();
    $cell = $g->booleanCell('{versionable}');
    echo $cell->renderBegin().$cell->renderChildren();
    if($currentRow['is_primary'] == FALSE && $currentRow['is_increment'] == FALSE && $currentRow['versionable'] == FALSE):
    echo '&nbsp;<a href="'.$this->buildUrl('*/*/*/change-version', array('id'=>$currentRow['id'])).'">'.$this->__('system.label.change_to_version').'</a>';
?>
<?php
    endif;
    echo $cell->renderEnd();
    echo $g->labelCell('{default_value}')->toHtml();
    echo $g->labelCell($this->__('system.label.'.$currentRow['input_type']))->toHtml();
    echo $g->linkCell($this->__('system.button.modify'), $this->buildUrl('*/*/*/edit', array('entityid'=>$currentRow['entity_id'], 'id'=>'{id}')))
            ->setStyle('text-align', 'center')
            ->toHtml();     
    echo $g->linkCell($this->__('system.button.delete'), $this->buildUrl('*/*/*/delete', array('id'=>'{id}')))
            ->setStyle('text-align', 'center')
            ->toHtml();      
	echo $g->renderRowEnd();
endwhile;
echo $g->renderEnd();

$this->nextBlock('pagination');
echo $this->pagination($this->recordCount)->toHtml();
$this->endBlock();

echo $this->extend('template'.DS.'list');